<script setup>
import { ref } from 'vue'
import { RouterView, useRouter } from 'vue-router'

const router = useRouter()
const activeMenu = ref('upload')

const navigateTo = (path) => {
  activeMenu.value = path
  router.push({ name: path })
}
</script>

<template>
  <div class="layout-container">
    <!-- 顶部导航栏 -->
    <header class="header">
      <div class="logo">
        <h1>图床系统</h1>
      </div>
      <div class="user-info">
        <span class="username">用户名</span>
        <button class="logout-btn">退出</button>
      </div>
    </header>
    
    <div class="main-container">
      <!-- 侧边栏菜单 -->
      <aside class="sidebar">
        <nav class="nav-menu">
          <div 
            class="menu-item" 
            :class="{ active: activeMenu === 'upload' }"
            @click="navigateTo('upload')"
          >
            <span>上传图片</span>
          </div>
          <div 
            class="menu-item" 
            :class="{ active: activeMenu === 'gallery' }"
            @click="navigateTo('gallery')"
          >
            <span>图片管理</span>
          </div>
          <div 
            class="menu-item" 
            :class="{ active: activeMenu === 'settings' }"
            @click="navigateTo('settings')"
          >
            <span>系统设置</span>
          </div>
        </nav>
      </aside>
      
      <!-- 主内容区域 -->
      <main class="content">
        <RouterView />
      </main>
    </div>
  </div>
</template>

<style scoped>
.layout-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

.header {
  height: 60px;
  background-color: #409EFF;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.logo h1 {
  margin: 0;
  font-size: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logout-btn {
  background: transparent;
  border: 1px solid white;
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 200px;
  background-color: #f4f4f5;
  border-right: 1px solid #e6e6e6;
  padding: 20px 0;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.3s;
  border-radius: 4px;
  margin: 0 10px;
}

.menu-item:hover {
  background-color: #e6f7ff;
}

.menu-item.active {
  background-color: #e6f7ff;
  color: #409EFF;
  font-weight: 500;
}

.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #f8f8f8;
}
</style>